package com.kaibes.module.user.safe;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.kaibes.module.user.UserService;
import com.kaibes.module.user.pojo.User;

@Component
public class Users {

    @Autowired
    private UserService userService;
    @Autowired
    private UserSafeService userSafeService;
    
    public User get(String email) {
        UserSafe userSafe = userSafeService.getUserIdByEmail(email);
        if (userSafe == null) {
            User user = new User();
            user.setNickname(email);
            return user;
        } else {
            return userService.getById(userSafe.getUserId());
        }
        
    }
}
